/**
 * 
 */
package com.eshopper.user.service;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eshopper.user.model.User;
import com.eshopper.user.repository.jpa.UserRepository;

/**
 * @author Arun Kumar, Nov 26, 2014
 *
 */
@Service
@Transactional
public class UserServiceImpl implements UserService{
	
	private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);

    @Resource
    private UserRepository repository;

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#addUser(com.eshopper.user.model.User)
	 */
	@Override
	public User addUser(User user) {
		LOGGER.info("Adding a new user entry with information: {}", user);

		User persisted = repository.save(user);

		return persisted;
	}

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#updateUser(com.eshopper.user.model.User)
	 */
	@Override
	public User updateUser(User user) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#getUsers()
	 */
	@Override
	public List<User> getUsers() {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#getUsersCount()
	 */
	@Override
	public int getUsersCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#deleteUser(java.lang.Long)
	 */
	@Override
	public void deleteUser(Long userId) {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#getUser(java.lang.Long)
	 */
	@Override
	public User getUser(Long userId) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#login(java.lang.String, java.lang.String)
	 */
/*	@Override
	public User login(String emailAddress, String password) {
		return repository.findByEmailAndPassword(emailAddress, password);
	}*/

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#findByEmailAndPassword(java.lang.String, java.lang.String)
	 */
/*	@Override
	public User findByEmailAndPassword(String emailAddress, String password) {
		return repository.findByEmailAndPassword(emailAddress, password);
	}*/

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#findUserByEmail(java.lang.String)
	 */
	@Override
	public User findUserByEmail(String emailAddress) {
		System.out.println("UserServiceImpl :: UserService = " + emailAddress);
		return repository.findByEmail(emailAddress);
	}

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#login(java.lang.String, java.lang.String)
	 */
	@Override
	public User login(String emailAddress, String password) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.eshopper.user.service.UserService#findByEmailAndPassword(java.lang.String, java.lang.String)
	 */
	@Override
	public User findByEmailAndPassword(String emailAddress, String password) {
		// TODO Auto-generated method stub
		return null;
	}
}
